package StudyCode.summary.mycollection;

import java.util.Arrays;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class MultipliesAnArrayOfDoublesAndAnArrayOfIntegersElementWise {
	public static void main(String[] argv) {
		double[] a = new double[]{34.45, 35.45, 36.67, 37.78, 37.0000,
				37.1234, 67.2344, 68.34534, 69.87700};
		int[] b = new int[]{34, 35, 36, 37, 37, 37, 67, 68, 69};
		System.out.println("double 数组与 int 数组元素一一对应乘积::");
		System.out.println(Arrays.toString(multiplyElementwise(a, b)));
	}

	public static double[] multiplyElementwise(double[] a, int[] b)
			throws ArithmeticException {

		if (a.length != b.length) {
			throw new ArithmeticException();
		} else {
			double[] result = new double[a.length];
			for (int i = 0; i < a.length; i++) {
				result[i] = a[i] * b[i];
			}
			return result;
		}

	}
}
